package com.zbkj.crmeb.test.task;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.constants.Constants;
import com.factory.TaskProcessEngineFactory;
import com.taobao.pac.sdk.cp.dataobject.request.MODUAN_ORDER_CREATE.request;
import com.utils.DateUtil;
import com.utils.vo.dateLimitUtilVo;
import com.zbkj.crmeb.chant.service.IChannelMerchantAccountService;
import com.zbkj.crmeb.merchant.api.service.MerOrderService;
import com.zbkj.crmeb.payment.service.OrderPayService;
import com.zbkj.crmeb.store.dao.StoreOrderDao;
import com.zbkj.crmeb.store.model.StoreOrderInfo;
import com.zbkj.crmeb.store.request.PushOrderRequest;
import com.zbkj.crmeb.store.request.StoreOrderSearchRequest;
import com.zbkj.crmeb.store.response.StoreCartResponse;
import com.zbkj.crmeb.store.response.StoreProductCartProductInfoResponse;
import com.zbkj.crmeb.store.service.StoreOrderService;
import com.zbkj.crmeb.store.service.UserCommissionService;
import com.zbkj.crmeb.system.model.SystemAdmin;
import com.zbkj.crmeb.task.order.GroupActivityTask;
import com.zbkj.crmeb.task.plat.poizon.PoizonOrderTask;
import com.zbkj.crmeb.task.plat.poizon.PoizonProductTask;
import com.zbkj.crmeb.task.plat.tiktok.TikTokApi;
import com.zbkj.crmeb.task.plat.tiktok.TikTokOrderTask;
import com.zbkj.crmeb.task.plat.tiktok.TikTokProductTask;
import com.zbkj.crmeb.test.BaseTest;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author Zhangxuyang
 * @date 4/28/2024 2:08 下午
 */
public class TikTokTask extends BaseTest {

    @Autowired
    TikTokApi tikTokApi;
    @Autowired
    TikTokOrderTask tikTokOrderTask;
    @Autowired
    TikTokProductTask tikTokProductTask;
    @Autowired
    MerOrderService merOrderService;
    @Autowired
    UserCommissionService userCommissionService;
    @Autowired
    OrderPayService orderPayService;

    @Autowired
    StoreOrderDao storeOrderDao;

    @Autowired
    GroupActivityTask groupActivityTask;

    @Test
    public void completeCommission() throws Exception {
        groupActivityTask.completeCommission();
    }

    @Test
    public void userCommissionTest() throws Exception {
        StoreOrderSearchRequest request = new StoreOrderSearchRequest();
        dateLimitUtilVo dateLimitUtilVo = DateUtil.getDateLimit(Constants.SEARCH_DATE_YEAR);
        request.setStartTime(dateLimitUtilVo.getStartTime());
        request.setEndTime(dateLimitUtilVo.getEndTime());
//        List<Integer> orderStatusList = Stream.of(1, 2, 3, 4).collect(Collectors.toList());
        List<Integer> orderStatusList = Stream.of(4).collect(Collectors.toList());
        request.setOrderStatusList(orderStatusList);

        List<StoreOrderInfo> storeOrderInfoList = storeOrderDao.listOrderByQuery(request);
        List<Integer> orderIds = storeOrderInfoList.stream().map(StoreOrderInfo::getOrderId).distinct().collect(Collectors.toList());
        for(Integer id : orderIds) {
            orderPayService.afterPaySuccessTest(id);
        }
    }

    @Test
    public void payTest() throws Exception {
        merOrderService.payTest();
    }

    @Test
    public void userCommisionTest() throws Exception {

//        userCommissionService.freezeUserCommissionV2();
    }

    @Test
    public void checkTikTokProductStock() throws Exception {
        tikTokProductTask.checkTikTokProductStock();
    }


    @Test
    public void pushProduct2DW() throws Exception {
//        tikTokApi.login();
    }

    @Test
    public void uploadProduct() throws Exception {
        tikTokOrderTask.uploadProduct();
    }
    @Test
    public void getOrder() throws Exception {
        tikTokOrderTask.fetch();
    }
}
